﻿using DrCarDrive.DBService;
using DrCarDrive.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DrCarDrive.Wpf.WpfPage
{
    /// <summary>
    /// Interaction logic for RecordHistory.xaml
    /// </summary>
    public partial class RecordHistory : Page
    {
        private static RecordHistory instance;
        public RecordHistory()
        {
            InitializeComponent();
            //List<tbl_drive> drives = new List<tbl_drive>();
            //drives.Add(new tbl_drive() { START_DATE = new DateTime(2005,12,1), END_DATE = new DateTime(2005,12,25), START_ODOMETER = 100, FROM = "Kandy", TO = "Kadugannawa", END_ODOMETER = 200 });
            //drives.Add(new tbl_drive() { START_DATE = new DateTime(2006, 12, 1), END_DATE = new DateTime(2006, 12, 25), START_ODOMETER = 200, FROM = "Katugastota", TO = "Kadugannawa", END_ODOMETER = 300 });           
        }

        public static RecordHistory Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new RecordHistory();
                }
                return instance;
            }
        }


        public void viewHistoryByCarID()
        {
           DriveService service = new DriveService();
           List<DriveHistoryView> driveHistoryViewList = new List<DriveHistoryView>();
           driveHistoryViewList = service.viewHistoryRecordByCarID(SessionData.car.ID);
           MessageBox.Show(driveHistoryViewList[0].DriveID);
       
        }

        private void Page_Loaded_1(object sender, RoutedEventArgs e)
        {
           // viewHistoryByCarID();
            
        }

        private void Page_Loaded_2(object sender, RoutedEventArgs e)
        {
            DriveService service = new DriveService();
            List<DriveHistoryView> driveHistoryViewList = new List<DriveHistoryView>();
            driveHistoryViewList = service.viewHistoryRecordByCarID(SessionData.car.ID);
            driveDataBinding.ItemsSource = driveHistoryViewList;
        }
    }
}
